Formatting a date field
The following ABAP code demonstrates a number of ways to format a SAP date value:
* Using the WRITE statement *************************** data: gd_date(10). "field to store output date * Converts SAP date from 20020901 to 01.09.2002 write sy-datum to gd_date dd/mm/yyyy. * Converts SAP date from 20020901 to 01.09.02 write sy-datum to gd_date dd/mm/yy.
* Using data manipulation techniques ************************************ data: gd_date(8). "field to store output date * Converts SAP date from 20010901 to 01092001 gd_date(2) = sy-datum+6(2). gd_date+2(2) = sy-datum+4(2). gd_date+4(4) = sy-datum(4).
* Using Function modules ************************ data: gd_date(8). "field to store output date * Converts date from 20010901 to 01SEP2001 gd_date = sy-datum. CALL FUNCTION 'CONVERSION_EXIT_IDATE_OUTPUT' EXPORTING input = gd_date IMPORTING OUTPUT = gd_date.
Related Articles
Add n number of working days to date (allow result to be a non working day)
Add n number of working days to date
Formatting SAP date field using ABAP into any format such as DDMMYYY, MM/DD/YYYY, DD-MMM-YY...
Check if date periods overlap
Add n number of working days to date
Add n number of working days to date
Convert month value of a date to text
Add n number of working days to date using SAP personal work schedule
Add n number of working days to date (using personal work schedule)